const {
	Controller
} = require('uni-cloud-router')
const uniID = require('uni-id')
module.exports = class RentController extends Controller {
	async getRentRecordDetail() {
		let {
			id
		} = this.ctx.data
		if (!id) {
			return {
				code: 500,
				msg: "参数错误"
			}
		}
		try{
			let record = await this.service.rent.getRentRecordDetail({
				id
			})
			return {
				code: 200,
				result: record
			}
		}catch(e){
			return {
				code: 500,
				msg: e.message
			}
		}
	}
	async confirmReturnRent() {
		let {
			rentRecordId,
			remarks,
			pledgeRefund = true
		} = this.ctx.data
		if (!rentRecordId) {
			return {
				code: 500,
				msg: '参数错误'
			}
		}
		return this.service.rent.confirmReturnRent({
			rentRecordId,
			remarks,
			pledgeRefund
		})
	}
	async getRentRecords() {
		let {
			storeId,
			pageNum = 1,
			pageSize = 20,
			keyword
		} = this.ctx.data
		try{
			let res = await this.service.rent.getRentRecords({
				storeId,
				pageNum,
				pageSize,
				keyword
			})
			return {
				code: 200,
				result: res
			}
		}catch(e){
			return {
				code: 500,
				msg: e.message
			}
		}
	}
}
